﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace StoreHouseA
{
    using StoreHouseDataSetTableAdapters;

    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            // TODO: 这行代码将数据加载到表“storeHouseDataSet.tb_agent”中。您可以根据需要移动或移除它。
            this.tb_agentTableAdapter.Fill(this.storeHouseDataSet.tb_agent);
            // TODO: 这行代码将数据加载到表“storeHouseDataSet.tb_level”中。您可以根据需要移动或移除它。
            this.tb_levelTableAdapter.Fill(this.storeHouseDataSet.tb_level);
            // TODO: 这行代码将数据加载到表“storeHouseDataSet.tb_customer”中。您可以根据需要移动或移除它。
            this.tb_customerTableAdapter.Fill(this.storeHouseDataSet.tb_customer);
            dateTimePicker1.Value = DateTime.Today;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            insert_in();
        }

        private void insert_in()
        {
            string in_customer = comboBox2.Text;
            string in_code = comboBox3.Text;
            string in_level = comboBox4.Text;
            string in_location = textBox4.Text;
            decimal in_weight = numericUpDown1.Value;
            DateTime in_date = dateTimePicker1.Value.Date;
            string in_agent = comboBox5.Text;
            string in_car = textBox7.Text;
            string in_memo = textBox8.Text;

            string in_oman = Program.oman;
            DateTime in_otime = DateTime.Now;

            tb_inoutTableAdapter a = new tb_inoutTableAdapter();
            a.Insert(in_code, in_level, in_customer, in_location, in_weight, 0,
                in_date, in_agent, in_car, "", "", "", in_memo, in_oman, in_otime);
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void textBox1_Click(object sender, EventArgs e)
        {

        }

        private void textBox2_Click(object sender, EventArgs e)
        {


        }

        private void textBox3_Click(object sender, EventArgs e)
        {

        }

        private void textBox4_Click(object sender, EventArgs e)
        {
            if (DialogResult.OK == (new Form17()).ShowDialog())
            {
                textBox4.Text = Form17.location_name;
            }
        }

        private void textBox6_Click(object sender, EventArgs e)
        {

        }

        private void button5_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                listView1.Items.Remove(listView1.SelectedItems[0]);
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (DialogResult.OK == (new Form40()).ShowDialog())
            {
                listView1.Items.Add(new ListViewItem(new string[] {
                    Form40.bag_code, Form40.bag_weight
                }));
            }
        }

        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void textBox4_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
